-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ReactScreen #170
base: main
Are you sure you want to change the base?
Add ReactScreen #170
Conversation
packages/library/src/react/index.ts
Outdated
onRun() { | ||
super.onRun() | ||
this.componentDiv = document.createElement('div') | ||
this.options.el?.appendChild(this.componentDiv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This usage of the el
option actually seems to have broken with the typescript update. I'm not seeing any active el
attached to components now, even at run
time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was part of the removal of runtime data from options
. The component el
is now part of the context
in which a component is presented, which in turn is added while the study is running. I think you should be able to access the specific component via this.internals.context.el
, cf. for example the canvas.Screen
code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I ended up doing is using global.rootEl
. Is there any meaningful difference between that and context.el
?
Another thing I did to make this nicer in the implementation of this in our library is add rootEl
to the global
interface in our equivalent of html.Screen
Hej Dano, thanks, this is fantastic! I think this is a great addition to the library, and something we should add for sure -- I don't see any blockers here. I'm worried about a slightly auxiliary issue, and that's bundling react with the library -- with the PR, both the distribution and development version roughly double in size, which feels a lot to me. I wonder whether we can somehow provide react as an optional external dependency, rather than bundling it by default? My hunch is that larger applications using react are going to bundle the library themselves, so I'm not sure we need to ship it in the default bundle. What do you think? Thanks a lot for all of your efforts, I truly appreciate it! Again, this is something we should absolutely include (as we have discussed before), I'd love to figure out the bundling. Kind regards, and many thanks, -Felix |
Thanks for looking into the bundle issue a bit more. I agree that increasing the bundle size that much is not great. Let's continue with the original plan of creating a new |
I also found it necessary in our library to provide another option, containerStyle, for allowing the parent div to be styled. Will include it. |
Let's discuss the status on this -- IIRC we discussed moving it into a separate package, but maybe I'm mistaken. Otherwise I just rebased my local branch and things are looking great, would love to have this in |
This PR introduces a new type of screen that can be used to integrate React components into lab.js.
Usage is very simple